/**
 * 
 */
package com.oauth.global.client.ui;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DecoratedStackPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.oauth.components.client.ui.CommonResources;
import com.oauth.components.client.ui.HasWidgetInfo;

/**
 * @author asanthan
 * 
 */
public class WidgetPanel extends Composite {

	private static WidgetPanelUiBinder uiBinder = GWT.create(WidgetPanelUiBinder.class);

	interface WidgetPanelUiBinder extends UiBinder<Widget, WidgetPanel> {
	}

	@UiField
	DecoratedStackPanel stackPanel;

	@UiField
	VerticalPanel vPanel;

	public WidgetPanel() {
		initWidget(uiBinder.createAndBindUi(this));
		// stackPanel.setStackText(0,
		// "<div class=\"stackText\">Each application</div>", true);
		setTitle("Home");
		stackPanel.addStyleName(CommonResources.INSTANCE.css().stackText());
	}

	public void setWidget(HasWidgetInfo widget) {
		vPanel.clear();
		vPanel.add(widget.getWidgetUI());
		setTitle(widget.getName());

	}

	public void setTitle(String title) {
		stackPanel.setStackText(0, "<div class=\"stackText\">" + title + "</div>", true);
	}

}
